SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.vwtAlumnoDivision
AS
SELECT     dbo.tb_AlumnoDivision.idRelDivisionAlumno AS ID, dbo.tb_Divisionestemp.Mnemo AS Division, dbo.tb_AlumnoDivision.Alumno, 
                      dbo.tb_AlumnoDivision.AnioLectivo, dbo.tb_AlumnoDivision.Desde, dbo.tb_AlumnoDivision.Hasta, dbo.tb_AlumnoDivision.InscripcionDeOrigen, 
                      dbo.tb_AlumnoDivision.Baja, dbo.tb_CausaBajaAlumno.Descripcion AS Causa_Baja
FROM         dbo.tb_AlumnoDivision LEFT OUTER JOIN
                      dbo.tb_Inscripciones ON dbo.tb_AlumnoDivision.InscripcionDeOrigen = dbo.tb_Inscripciones.idInscripcion LEFT OUTER JOIN
                      dbo.tb_CausaBajaAlumno ON dbo.tb_AlumnoDivision.CausaBaja = dbo.tb_CausaBajaAlumno.IdCausa LEFT OUTER JOIN
                      dbo.tb_Divisionestemp ON dbo.tb_AlumnoDivision.Division = dbo.tb_Divisionestemp.idDivision

GO
GRANT SELECT ON  [dbo].[vwtAlumnoDivision] TO [Alumnos]
GRANT SELECT ON  [dbo].[vwtAlumnoDivision] TO [Informatica]
GRANT SELECT ON  [dbo].[vwtAlumnoDivision] TO [SoloVer]
GO
